module.exports = (plop) => {
  plop.setHelper("capitalizeFirstLetter", function (string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
  });
  plop.setGenerator("page", {
    description: "create a curdPage",
    prompts: [
      {
        type: "input",
        name: "system",
        message: "system‘s name",
        default: "qms",
      },
      {
        type: "input",
        name: "module",
        message: "module‘s name",
        default: "inspectionManagement",
      },
      {
        type: "input",
        name: "sub_module",
        message: "sub_module‘s name",
      },
      {
        type: "input",
        name: "name",
        message: "页面name",
      },
      {
        type: "input",
        name: "title",
        message: "页面标题",
      },
      {
        type: "confirm",
        name: "isFormTable",
        message: "表单有没有表格",
      },
      {
        type: "confirm",
        name: "isShowDetail",
        message: "是否需要详情页",
      },
      {
        type: "input",
        name: "field",
        message: "表格在表单中的字段:",
        when: (answers) => answers.isFormTable, // 当 isFormTable 为 true 时显示
      },
    ],
    actions: [
      {
        type: "add", // 添加文件
        path: "src/views/{{system}}/{{module}}/{{sub_module}}/{{name}}/{{name}}.vue",
        templateFile: "plop-templates/component.hbs",
      },
    ],
  });
  plop.setGenerator("selectModal", {
    description: "create a selectModal",
    prompts: [
      {
        type: "input",
        name: "system",
        message: "system‘s name",
        default: "wms",
      },
      {
        type: "input",
        name: "name",
        message: "文件名",
      },
      {
        type: "input",
        name: "title",
        message: "页面标题",
      },
      {
        type: "input",
        name: "api",
        message: "接口名称",
      },
    ],
    actions: [
      {
        type: "add", // 添加文件
        path: "src/busComponents/{{system}}/{{module}}/{{sub_module}}/{{name}}.vue",
        templateFile: "plop-templates/selectModal.hbs",
      },
    ],
  });
};
